<template>
  <el-container class="container">
    <el-header>
      
      <el-row>
        <el-col :span="6"><div class="main-title"><h1>ZT-BLOG</h1></div></el-col>
        <el-col :span="2" :offset="14" class="main-title"><el-button type="text" @click="gofront()" >前台</el-button></el-col>
        <el-col :span="2" class="main-title"><el-button type="primary" @click="logout()" >退出</el-button></el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside :width="collapsed ? '64px' : '200px'">
        <div class="aside-close" @click="coll()">
          <i
            :class="collapsed ? 'el-icon-arrow-right' : 'el-icon-arrow-left'"
          ></i>
        </div>
        <!-- 导航菜单 -->
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#435970"
          text-color="#fff"
          active-text-color="#ffd04b"
          :collapse-transition="false"
          :collapse="collapsed"
          unique-opened
          router
        >
          <!-- 博客管理 -->
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-edit-outline"></i>
              <span>博客管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/blog">查询博客</el-menu-item>
              <el-menu-item index="/insertblog">添加博客</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <!-- 标签管理 -->
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-price-tag"></i>
              <span>标签管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/tag">查询标签</el-menu-item>
              <el-menu-item index="insertTag">标签操作</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <!-- 评论管理 -->
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-chat-line-square"></i>
              <span>分类管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/sorts">查询分类</el-menu-item>
              <el-menu-item index="insertSort">分类操作</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <!-- 留言管理 -->
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-chat-line-round"></i>
              <span>评论管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/comments">所有评论</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <!-- 账户信息 -->
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-setting"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/userInfo">个人信息</el-menu-item>
              <el-menu-item index="/changeUser">修改信息</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      collapsed: false,
    };
  },
  methods: {
    coll() {
      this.collapsed = !this.collapsed;
    },
    gofront(){
      this.$router.push("/")
    },
    logout(){
      window.sessionStorage.clear();
      this.$router.push("/h_login")
    }
  },
};
</script>
<style scoped>
.el-header {
  background-color: #25313f;
}
.el-aside {
  background: #435970;
}
.el-main {
  background-color: #e9edf1;
}
.container {
  height: 100%;
}
.el-menu {
  border-right: none;
}
.main-title {
  line-height: 60px;
  color: white;
}
.aside-close {
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #869394;
}
</style>